﻿<Window x:Class="AmazonGlacierGUI.UI.Views.VaultBrowser"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:AmazonGlacier="clr-namespace:AmazonGlacierGUI.Core.Helpers.AmazonGlacier;assembly=AmazonGlacierGUI.Core"
        xmlns:System="clr-namespace:System;assembly=mscorlib" Title="Browse Vaults" Height="300" Width="369" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ObjectDataProvider x:Key="regionEnum"
       MethodName="GetValues" ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="AmazonGlacier:AmazonRegionEnum"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition  Height="20"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Region"></TextBlock>
                <ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Source={StaticResource regionEnum}}"
                          SelectedItem="{Binding Region,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}"
                          ></ComboBox>
            </Grid>
            <TextBlock Text="Loading..." Visibility="{Binding IsBusy,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock>
            <Button Content="Refresh from amazon" Command="{Binding ReloadCommand}" Width="130" HorizontalAlignment="Left" ></Button>            
        </StackPanel>
        <DataGrid x:Name="dg" Grid.Row="1" AutoGenerateColumns="False" ItemsSource="{Binding Vaults}" IsReadOnly="True"
                   SelectedItem="{Binding SelectedVault,Mode=TwoWay}" Margin="0,5,0,0" >
            <DataGrid.Columns>
                <DataGridTextColumn Header="Vault name" Binding="{Binding  VaultName}"/>
                <DataGridTextColumn Header="Archive count" Binding="{Binding  NumberOfArchives}"/>
                <DataGridTextColumn Header="Total bytes" Binding="{Binding  TotalSize}"/>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel Grid.Row="2"  Orientation="Horizontal" Margin="0,5,0,0">
            <Button Content="Ok" Width="81" HorizontalAlignment="Left"  Command="{Binding OkCommand}"></Button>
            <Button Content="Cancel" Width="83" HorizontalAlignment="Left" Margin="5,0,0,0" Command="{Binding CloseCommand}"></Button>
        </StackPanel>
        
        
    </Grid>
</Window>
